package net.esj.sms;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

public class SMSUtils {
	
	
	/**阿里大鱼*/
	public static boolean AlibabaSMSSend(String phone,String code){
		TaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest", "23453606", "9f8eca1620dd78985af8afbeeefc54ee");
		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
		req.setExtend("123456");//公告回传值
		req.setSmsType("normal");//短信类型
		req.setSmsFreeSignName("登录验证");//短信签名
		req.setSmsParamString("{'code':'"+code+"','product':'车壹'}");//短信模板
		req.setRecNum(phone);//短信接收好吗
		req.setSmsTemplateCode("SMS_10235198");//短信模板ID
		try {
			AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
			if(rsp.getResult().getSuccess()){
				return true;
			}
			System.out.println(rsp.getBody());
		} catch (ApiException e) {
			e.printStackTrace();
		}
		return false;
	}

}
